package tech.aistar.mapper.services;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;
import tech.aistar.vo.ServicesAndNameQueryVo;

import java.util.List;

/**
 * @Author: lya
 * @Description: 本类的作用描述:服务Mapper层接口
 * @CreateDate: 2019/9/29
 * @Version: 1.0
 */
@Repository
public interface ServicesListMapper {
    /**
     * 根据服务名称模糊查询
     */
    List<ServicesAndNameQueryVo> findServicesByName(String title);

    /**
     * 根据类别查询
     */
    @Select("select s.* ,u.name from services s join user_info u on s.userinfo_id = u.id where s.category_id = #{value} and end_time = now()")
    List<ServicesAndNameQueryVo> findServicesByCategory(Integer categoryId);

    /**
     * 根据详细类别查询
     */
    @Select("select s.* ,u.name from services s join user_info u on s.userinfo_id = u.id where s.categorydetail_id = #{value} and s.end_time > now()")
    List<ServicesAndNameQueryVo> findServicesByCategoryDetail(Integer categorydetailId);

    /**
     * 根据成交数降序排序
     */
    @Select("select s.* ,u.name from services s join user_info u on s.userinfo_id = u.id where s.end_time > now() order by s.count desc")
    List<ServicesAndNameQueryVo> findServicesByCount();

    /**
     * 根据发布时间降序排序
     */
    @Select("select s.* ,u.name from services s join user_info u on s.userinfo_id = u.id where s.end_time > now() order by s.begin_time desc")
    List<ServicesAndNameQueryVo> findServicesBybeginTime();

    /**
     * 根据价格降序排序
     */
    @Select("select s.* ,u.name from services s join user_info u on s.userinfo_id = u.id where s.end_time > now() order by s.price desc")
    List<ServicesAndNameQueryVo> findServicesByPriceDesc();

    /**
     * 根据价格升序排序
     */
    @Select("select s.* ,u.name from services s join user_info u on s.userinfo_id = u.id where s.end_time > now() order by s.price")
    List<ServicesAndNameQueryVo> findServicesByPrice();

    /**
     * 根据价格区间查询
     */
    List<ServicesAndNameQueryVo> findServicesByPriceRange(@Param("minPrice") Double minPrice, @Param("maxPrice") Double maxPrice);

    /**
     * 查询服务和用户昵称
     */
    @Select("select s.* ,u.name from services s join user_info u on s.userinfo_id = u.id where s.end_time > now()")
    List<ServicesAndNameQueryVo> findServicesAndName();




}
